<template>
  <div class="comStatement">
    <h2>综合报表</h2>

    <div class="box">
      <div class="block">
        <span class="demonstration">时间段 </span>
        <el-date-picker v-model="timeInterval" type="daterange"
          range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
        </el-date-picker>
      </div>
      <div class="btnBox">
        <div class="btnBox-left">
          <el-button type="primary" @click="getBusinessData">计算</el-button>
          <el-button type="success" @click="reset">重置</el-button>
        </div>
        <div class="btnBox-right">
          <el-button v-print="'#printTest'">
            <i class="el-icon-printer"></i>
            打印</el-button>
        </div>
      </div>
    </div>
    <div class="tableBox" id="printTest">
      <el-table border :data="diagnosisData" style="width: 100% "
        :header-cell-style="{ background: '#dddddd', color: 'black' }"
        class="table">
        <el-table-column prop="diagnosis" label="诊断统计" min-width="14%">
        </el-table-column>
        <el-table-column prop="status0" label="新开单" min-width="15%">
        </el-table-column>
        <el-table-column prop="status1" label="进行中 " min-width="15%">
        </el-table-column>
        <el-table-column prop="status2" label="已完成" min-width="15%">
        </el-table-column>
        <el-table-column prop="status3" label="已暂停" min-width="15%">
        </el-table-column>
        <el-table-column prop="status4" label="已取消" min-width="15%">
        </el-table-column>
        <el-table-column prop="total" label="总数" min-width="11%">
        </el-table-column>
      </el-table>

      <el-table border :data="customerServiceData" style="width: 100%"
        :header-cell-style="{ background: '#dddddd', color: 'black' }"
        class="table">
        <el-table-column prop="customerService" label="客服统计" min-width="14%">
        </el-table-column>
        <el-table-column prop="status1" label="新客服" min-width="18%">
        </el-table-column>
        <el-table-column prop="status2" label="处理中 " min-width="18%">
        </el-table-column>
        <el-table-column prop="status3" label="已完成" min-width="18%">
        </el-table-column>
        <el-table-column prop="status4" label="已取消" min-width="18%">
        </el-table-column>
        <el-table-column prop="total" label="总数" min-width="14%">
        </el-table-column>
      </el-table>

      <el-table border :data="marketingData" style="width: 100%"
        :header-cell-style="{ background: '#dddddd', color: 'black' }"
        class="table">
        <el-table-column prop="marketing" label="营销统计" min-width="14%">
        </el-table-column>
        <el-table-column prop="newActivities" label="新活动" min-width="15%">
        </el-table-column>
        <el-table-column prop="inProgress" label="进行中 " min-width="15%">
        </el-table-column>
        <el-table-column prop="completed" label="已完成" min-width="15%">
        </el-table-column>
        <el-table-column prop="paused" label="已暂停" min-width="15%">
        </el-table-column>
        <el-table-column prop="canceled" label="已取消" min-width="15%">
        </el-table-column>
        <el-table-column prop="total" label="总数" min-width="11%">
        </el-table-column>
      </el-table>
    </div>





    <!-- 表格 -->






  </div>
</template>
<script>


import dayjs from 'dayjs';

export default {
  name: '',
  components: {

  },
  mixins: [],
  props: {

  },
  data() {
    return {
      timeInterval: '',
      startTime: '2023-02-20',
      endTime: '2023-02-30',
      diagnosisData: [],
      customerServiceData: [],
      marketingData: [{
        marketing: "2023/02/01-2023/02/16",
        newActivities: 1,
        inProgress: 0,
        completed: 0,
        paused: 0,
        canceled: 0,
        total: 1
      }],
      value1: "",
      value2: "",
    }
  },
  computed: {

  },
  watch: {

  },
  created() {
    this.businessData(this.startTime, this.endTime);
  },
  methods: {
    dayjs,
    getBusinessData() {
      this.startTime = dayjs(this.timeInterval[0]).format('YYYY-MM-DD')
      this.endTime = dayjs(this.timeInterval[1]).format('YYYY-MM-DD')
      this.businessData(this.startTime, this.endTime);
    },
    async businessData(startTime, endTime) {
      let res = await this.$api.business.getBusinessList({ startTime, endTime })
      this.diagnosisData=[];
      this.customerServiceData=[];
      this.diagnosisData.push({ diagnosis: this.startTime + "至" + this.endTime, ...res.data.data.diagnosisRes });
      this.customerServiceData.push({ customerService: this.startTime + "至" + this.endTime, ...res.data.data.customerRes })
      console.log(this.diagnosisData, this.customerServiceData);
    },
    reset() {
      this.timeInterval = '';
    },
  }
};
</script>
<style lang='less' scoped>
h2 {
  margin: 15px
}

.box {
  background-color: white;
  margin: 0 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  border-top: 3px solid #ccc;
  border-radius: 5px;
}

.block {
  // width: 100%;
  padding: 15px;

  border: 1px solid #dfe4ea;
  border-right: 0;
}

.btnBox {
  height: 60px;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #dfe4ea;

  .btnBox-left {
    margin-left: 10px;
  }

  .btnBox-right {
    margin-right: 10px;
  }
}


.tableBox {
  margin: 0 10px;
  padding: 20px 20px;
  background-color: white;
  border: 1px solid #def4ea;

}

.comStatement {
  height: 100%;
}

.table {
  margin-bottom: 25px;
}

body {
  height: 100%;
}

html {
  height: 100%;
}
</style>